package com.esiag.pdsteam.treatcomplexinfo;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

import com.esiag.pdsteam.entities.Information;
import com.esiag.pdsteam.entities.TypeComlexInfo;

public class MainFindComplexInfo {

	private void start() {
		FindComplexInfo findComplexInfo= new FindComplexInfo();
		List<Information> informations = new ArrayList<Information>();
		TypeComlexInfo typeComlexInfo1 = new TypeComlexInfo();
		typeComlexInfo1.setId(1);
		typeComlexInfo1.setTyp("Critique");
		Information information1 = new Information(3,"Oxygene",typeComlexInfo1,null);
		Information information2 = new Information(2,"Temperature",typeComlexInfo1,null);
		informations.add(information2);
		informations.add(information1);
		
		Information information6 = new Information(6,"Dilatation Rail",typeComlexInfo1,null);
		Information information7 = new Information(7,"Vitesse",typeComlexInfo1,null);
		informations.add(information6);
		informations.add(information7);
		
		TypeComlexInfo typeComlexInfo2 = new TypeComlexInfo();
		typeComlexInfo2.setId(2);
		typeComlexInfo2.setTyp("NonCritique");
		Information information4 = new Information(4,"Heure",typeComlexInfo2,null);
		informations.add(information4);
		findComplexInfo.manageComplexInfo(information1);
		findComplexInfo.manageComplexInfo(information2);
		findComplexInfo.manageComplexInfo(information4);
		findComplexInfo.manageComplexInfo(information6);
		findComplexInfo.manageComplexInfo(information7);
		
		
		FileHandler fileHandler;
		
			try {
				fileHandler = new FileHandler("GhitaBenComplexInfo.log");
				final Logger logger = Logger.getLogger("loger");
				logger.addHandler( fileHandler);
				SimpleFormatter formatter = new SimpleFormatter();  
	            fileHandler.setFormatter(formatter);  
	            logger.log(Level.INFO, "Simple Information 1: " +information1 );
	            logger.log(Level.INFO, "Simple Information 1: " +information2 );
	            logger.log(Level.INFO, "Simple Information 1: " +information4 );
	            logger.log(Level.INFO, "Simple Information 1: " +information6 );
	            logger.log(Level.INFO, "Simple Information 1: " +information7 );
	            logger.log(Level.INFO, "Simple and Complex Information : " +findComplexInfo.get_piles() );
			} catch (SecurityException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

			
		
		System.out.println(findComplexInfo.get_piles());
	}

	public static void main(String[] args) {
		MainFindComplexInfo main = new MainFindComplexInfo();
		main.start();

	}

}
